package com.ajx.core.net.rest;

import android.util.Log;

import com.ajx.core.app.ConfigKeys;
import com.ajx.core.app.Cube;

import okhttp3.Interceptor;

import java.util.ArrayList;
import java.util.List;

public class CubeRestBuilder {

    private List<Interceptor> interceptors=new ArrayList<>();
    private long readTime;
    private String ip;
    private long connectTime;

    public CubeRest build(){
        if (ip==null){
            ip= Cube.getConfiguration(ConfigKeys.API_HOST);
        }
        if (readTime==0){
            readTime=30;
        }
        if (connectTime==0){
            connectTime=30;
        }
        return new CubeRest(this.ip,this.readTime,this.connectTime,this.interceptors);
    }

    public CubeRestBuilder connectTime(long connectTime){
        this.connectTime=connectTime;
        return this;
    }
    public CubeRestBuilder readTime(long readTime){
        this.readTime=readTime;
        return this;
    }
    public CubeRestBuilder baseUrl(String baseUrl){
        this.ip=baseUrl;
        return this;
    }

    public CubeRestBuilder addInterceptor(Interceptor interceptor){
        this.interceptors.add(interceptor);
        return this;
    }

    public CubeRestBuilder interceptors(List<Interceptor> interceptors){
        this.interceptors.addAll(interceptors);
        return this;
    }

}
